//
// Created by wze-zero on 2024/10/21.
//
#include <iostream>
#include <cmath>

using namespace std;

bool check(int num) {
    int temp = num, sum = 0;
    while (temp % 10 || temp / 10) {
        sum += (int) pow(temp % 10, 4);
        temp /= 10;
    }
    return num == sum;
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = n; i < m + 1; ++i) {
        if (check(i)) {
            cout << i << ' ';
        }
    }
}